<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>点击变化字体大小</title>
</head>

<body>
    <input type="button" id="btn1" value="字体20px">
    <input type="button" id="btn2" value="字体40px">
    <input type="button" id="btn3" value="字体80px">
    <p>看看我的大小吧，少年郎</p>
    <script type="text/javascript">
        // var txt = document.getElementById('txt');
        var btn1 = document.getElementById('btn1');
        var btn2 = document.getElementById('btn2');
        var btn3 = document.getElementById('btn3');
        var txt = document.getElementById('txt');

        function changeFs(fSize) {
            return function() {
                // txt.style.fontSize = fSize + 'px';
                document.body.style.fontSize = fSize + 'px';
            }
        }
        btn1.onclick = changeFs(20);
        btn2.onclick = changeFs(40);
        btn3.onclick = changeFs(80);
    </script>
</body>

</html>